
#include "member_BMovie.h"
#include "member_BTexture.h"
#include "member_BImage.h"

using namespace BWE;

member_BMovie::member_BMovie(BMovie* movie)
{
	boss = movie;
	current = 0;
	tick = 0;
	duration = 1;
	speed = 100;
	loop = true;
	paused = false;
	dirty = true;
}
member_BMovie::~member_BMovie()
{

}

void member_BMovie::update(BReal time)
{
	if (paused)
		return;
	if (pixelsArray.size() <= 1)
		return;
	BReal interval = duration / pixelsArray.size();
	if (time - tick > interval)
	{
		tick = time;
		if (current < 0)
			current = 0;
		if (current >= pixelsArray.size())
			current = pixelsArray.size() - 1;
		if (current == pixelsArray.size() - 1)
		{
			if (!loop)
				return;
			current = 0;
		}
		else
		{
			current++;
		}
		dirty = true;
		image_member(boss)->dirty = true;
		texture_member(boss)->dirty = true;
		boss->emit(Signal_Dirty);
	}
}
